package com.ml.mall.api.seting;

import com.ml.mall.bean.base.ApiRestResult;
import com.ml.mall.bean.req.seting.SetingEditDto;
import com.ml.mall.bean.req.seting.SetingNewDto;
import com.ml.mall.consts.PermissionConst;
import com.ml.mall.service.seting.SysASetingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 *   @description    :description 
 *   @author         :zxm
 *   @date           :2021/5/19
 *   @version        :1.0
**/
@Api(tags = "【auth】系统设置相关接口")
@RestController
@RequestMapping("/seting")
public class SetingController {

    @Autowired
    private SysASetingService sysASetingService;

    @ApiOperation(value = "系统设置新增")
    @PostMapping("/new")
//  @RequiresPermissions(PermissionConst.SETING_NEW)//未发现调用
    public ApiRestResult setingNew(@RequestBody @Valid SetingNewDto dto){
        sysASetingService.createSeting(dto);
        return ApiRestResult.ok();
    }

    @ApiOperation(value = "系统设置修改")
    @PostMapping("/edit")
//  @RequiresPermissions(PermissionConst.SETING_EDIT)//未发现调用
    public ApiRestResult setingEdit(@RequestBody @Valid SetingEditDto dto){
        sysASetingService.editSeting(dto);
        return ApiRestResult.ok();
    }

    @ApiOperation(value = "系统设置全查询")
    @PostMapping("/query_seting")
//  @RequiresPermissions(PermissionConst.SETING_QUERY_SETING)//未发现调用
    public ApiRestResult setingQueryList(){
        return ApiRestResult.ok(sysASetingService.queryListSeting());
    }

}
